package utils;

public class UnicodeUtils {

	
	public static String toUnicodeString(String input){
		String output = "";
		
		if(input==null) return output;
		
		for(char ch : input.toCharArray()){
			String temp = "0000"+Integer.toHexString(ch);
			temp = temp.substring(temp.length()-4).toUpperCase();
			output+= temp;
		}
		
		return output;
	}
	
	public static String toStringFromUnicodeString(String unicodeString){
		String output = "";
		
		if(unicodeString==null) return output;
		
		int index = 0;
		int i=0;
		for(String sub= unicodeString.substring(0, 4);sub.length()==4;i++,sub = unicodeString.substring(i*4, (i*4+4)>unicodeString.length()?unicodeString.length():(i*4+4))){
			int unicode = Integer.parseInt(sub, 16);
			char ch = (char) unicode;
			output += ch;
			index++;
		}
		
		
		return output;
	}
	
	
	public static void main(String[] args) {
		System.out.println(toStringFromUnicodeString("006A0070006700740061006D0061"));
	}
	
}
